import request from '@/utils/request'

// 消息中心 未读
export function getUnreadMsgAPI(page = 0, size = 10) {
  return request({
    url: 'api/message/unReadMessages',
    params: {
      page,
      size,
      sort: 'createdAt,desc'
    }
  })
}

// 消息中心 已读
export function getReadMsgAPI(page = 0, size = 10) {
  return request({
    url: 'api/message/readMessages',
    params: {
      page,
      size,
      sort: 'createdAt,desc'
    }
  })
}

// 消息中心 未读变为已读
export function changeReadMsgAPI (id) {
  return request({
    url: 'api/message/read?id=' + id,
    method: 'post',
  })
}

// 物料申领
export function createStorehouseOrderAPI (data, note) {
  return request({
    url: `api/storehouseOrder/create`,
    // url: `api/storehouseOrder/create?data=${data}&note=${note}`,
    method: 'post',
    data: {
      data,
      note
    },
    Headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}

// 物料申领记录列表
export function getAuditPersonalListAPI (params, page = 0, size = 10,) {
  return request({
    url: 'api/storehouseOrder/auditPersonalList',
    params: {
      page,
      size,
      ...params,
      sort: 'createdAt,desc'
    }
  })
}

// 实验室预约记录列表
export function getAppointmentListAPI(params, page = 0, size = 10,) {
  return request({
    url: 'api/labBusyTime/queryLabBusyTimeSelf',
    params: {
      page,
      size,
      ...params,
      sort: 'createdAt,desc'
    }
  })
}

// 可预约时间
export function getAppointmentTimeAPI(id) {
  return request({
    url: 'api/labTime/queryLabTime?labId=' + id
  })
}

// 申领记录的取消
export function cancelReveiveAPI (id) {
  return request({
    url: 'api/storehouseOrder/cancel?id=' + id,
    method: 'post',
  })
}

// 申领记录的删除
export function delReveiveAPI (id) {
  return request({
    url: 'api/storehouseOrder/delete?id=' + id,
    method: 'post',
  })
}

// 取消实验室预约
export function cancelAppointmentAPI (id) {
  return request({
    url: 'api/labBusyTime/cancel?id=' + id,
    method: 'post',
  })
}

// 删除实验室预约
export function delAppointmentAPI (id) {
  return request({
    url: 'api/labBusyTime',
    method: 'delete',
    data: [id]
  })
}

//新增预约
export function addAppointmentAPI (data) {
  return request({
    url: 'api/labBusyTime',
    method: 'post',
    data
  })
}

// 查询可预约实验室
export function getAppointmentLabAPI (data) {
  return request({
    url: 'api/labTime/queryLab',
  })
}

// 个人项目列表
export function getProjectListAPI () {
  return request({
    url: 'api/project/userProjectList',
  })
}

//领用接口
export function toGetProductAPI (data) {
  return request({
    url: 'api/storehouseOrder/delivery',
    method: 'post',
    data
  })
}

// 领用清单
export function getStorehouseDetailAPI (id) {
  return request({
    url: 'api/storehouseOrderDetail/list?id=' + id,
  })
}

//归还列表api/storehouseOrderDetail/returnList
export function returnListAPI (params, page = 0, size = 10) {
  return request({
    url: 'api/storehouseOrderDetail/returnList',
    params: {
      page,
      size,
      ...params,
      sort: 'createdAt,desc'
    }
  })
}

// 归还
export function returnStorehouseDetailAPI (data) {
  return request({
    url: 'api/storehouseOrderDetail/return',
    method: 'post',
    data
  })
}

//归还列表删除
export function returnDelAPI (data) {
  return request({
    url: 'api/storehouseOrderDetail',
    method: 'delete',
    data
  })
}
